package com.yiwei.app.modules.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yiwei.app.modules.dao.ContractInfoMapper;
import com.yiwei.app.modules.dao.CustomerInfoMapper;
import com.yiwei.app.modules.dao.DeliveryOrderInformationMapper;
import com.yiwei.app.modules.dao.OrderInfoMapper;
import com.yiwei.app.modules.entity.ContractInfo;
import com.yiwei.app.modules.entity.CustomerInfo;
import com.yiwei.app.modules.entity.DeliveryOrderInformation;
import com.yiwei.app.modules.entity.OrderInfo;


@Service
public class OrderService {
     
	
	/*******
	 * 订单信息service
	 */
	@Resource
	private OrderInfoMapper orderInfoMapper;
	/******
	 * 插入订单信息
	 * @param orderinfo
	 * @return
	 */
	public boolean insertorderInfo(OrderInfo orderInfo){
		return orderInfoMapper.insertSelective(orderInfo)==1?true:false;
	}
	/******
	 * 更改订单信息
	 * @param orderinfo
	 * @return
	 */
	public boolean updateorderInfo(OrderInfo orderInfo){
		return orderInfoMapper.updateByPrimaryKeySelective(orderInfo)==1?true:false;
	}
	/********
	 * 删除订单信息(此为逻辑删除)
	 * @param delFlag
	 * @param id
	 * @return
	 */
	public boolean deleteorderInfo(String delFlag,String id){
		return orderInfoMapper.updateflag(delFlag,id)==1?true:false;
	}
	/******
	 * 按照id查询订单信息
	 * @param id
	 * @return
	 */
	public OrderInfo selectbyOrderInfoId(String id){
		return orderInfoMapper.selectByPrimaryKey(id);
	}
	/*******
	 * 分页查询订单信息
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	public List selectOrderInfoList(String pageNum,String pageSize){
		return orderInfoMapper.selectlist(pageNum, pageSize);
	}
	
	/*********
	 * 配送订单信息
	 */
	@Resource
	private DeliveryOrderInformationMapper deliveryOrderInformationMapper;
	/******
	 * 插入配送订单信息
	 * @param deliveryorderinfo
	 * @return
	 */
	public boolean insertDeliveryOrder(DeliveryOrderInformation deliveryorderInfo){
		return deliveryOrderInformationMapper.insertSelective(deliveryorderInfo)==1?true:false;
	}
	/*******
	 * 更改配送订单信息
	 * @param deliveryorderinfo
	 * @return
	 */
	public boolean updateDeliveryOrder(DeliveryOrderInformation deliveryorderInfo){
		return deliveryOrderInformationMapper.updateByPrimaryKey(deliveryorderInfo)==1?true:false;
	}
	/*******
	 * 删除配送订单信息(此为逻辑删除配送订单信息)
	 * @param delFlag
	 * @param id
	 * @return
	 */
	public boolean deleteDeliveryOrderbyId(String delFlag,String id){
		return deliveryOrderInformationMapper.updateflag(delFlag,id)==1?true:false;
	}
	/**********
	 * 按照id查询配送订单信息
	 * @param id
	 * @return
	 */
	public DeliveryOrderInformation selectDeliveryOrderInfoById(String id){
		return deliveryOrderInformationMapper.selectByPrimaryKey(id);
	}
	/********
	 * 分页查询配送订单信息
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	public List<DeliveryOrderInformation> selectDeliveryOrderInfoList(String pageNum,String pageSize){
		return deliveryOrderInformationMapper.selectDeliveryOrderList(pageNum, pageSize);
	}
	
	
	
	/*********
	 * 大客户信息
	 */
	@Resource
	private CustomerInfoMapper customerInfoMapper;
	/******
	 * 插入大客户信息
	 * @param customerInfo
	 * @return
	 */
	public boolean insertCustomerInfo(CustomerInfo customerInfo){
		return customerInfoMapper.insertSelective(customerInfo)==1?true:false;
	}
	/*******
	 * 更改大客户信息
	 * @param customerInfo
	 * @return
	 */
	public boolean updateCustomerInfo(CustomerInfo customerInfo){
		return customerInfoMapper.updateByPrimaryKey(customerInfo)==1?true:false;
	}
	/*******
	 * 删除大客户信息(此为逻辑删除大客户信息)
	 * @param delFlag
	 * @param id
	 * @return
	 */
	public boolean deleteCustomerInfobyId(String delFlag,String id){
		return customerInfoMapper.updateflag(delFlag,id)==1?true:false;
	}
	/**********
	 * 按照id查询大客户信息
	 * @param id
	 * @return
	 */
	public CustomerInfo selectCustomerInfoById(String id){
		return customerInfoMapper.selectByPrimaryKey(id);
	}
	/********
	 * 分页查询大客户信息
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	public List<CustomerInfo> selectCustomerInfoList(String pageNum,String pageSize){
		return customerInfoMapper.selectCustomerInFO(pageNum, pageSize);
	}
	
	/*********
	 * 合同信息
	 */
	@Resource
	private ContractInfoMapper contractInfoMapper;
	/******
	 * 插入大客户信息
	 * @param customerInfo
	 * @return
	 */
	public boolean insertContractInfo(ContractInfo contractInfo){
		return contractInfoMapper.insertSelective(contractInfo)==1?true:false;
	}
	/*******
	 * 更改大客户信息
	 * @param customerInfo
	 * @return
	 */
	public boolean updateContractInfo(ContractInfo contractInfo){
		return contractInfoMapper.updateByPrimaryKey(customerInfo)==1?true:false;
	}
	/*******
	 * 删除大客户信息(此为逻辑删除大客户信息)
	 * @param delFlag
	 * @param id
	 * @return
	 */
	public boolean deleteContractInfobyId(String delFlag,String id){
		return contractInfoMapper.updateflag(delFlag,id)==1?true:false;
	}
	/**********
	 * 按照id查询大客户信息
	 * @param id
	 * @return
	 */
	public ContractInfo selectContractInfoById(String id){
		return contractInfoMapper.selectByPrimaryKey(id);
	}
	/********
	 * 分页查询大客户信息
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	public List<ContractInfo> selectContractInfoList(String pageNum,String pageSize){
		return contractInfoMapper.selectCustomerInFO(pageNum, pageSize);
	}
}
